package com.hank.brokerrun;

import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;

import java.net.URI;

public class RunBroker {

    public static void main(String[] args) throws Exception {
        runBrokerService();

//        runBrokerFactory();
    }

    public static void runBrokerService() throws Exception {
        BrokerService brokerService = new BrokerService();
        brokerService.setUseJmx(true);//开启监控
        brokerService.setPersistent(true); //持久化
        brokerService.setBrokerName("ITPub");
        brokerService.addConnector("tcp://127.0.0.1:61616");
        brokerService.start();
        System.out.println("Broker 启动成功!");
    }

    public static void runBrokerFactory() throws Exception {
        String uri = "properties:activemq.properties";
        BrokerService brokerService =BrokerFactory.createBroker(new URI(uri));
        brokerService.addConnector("tcp://127.0.0.1:61616");
        brokerService.start();
        System.out.println("Broker 启动成功!");
    }


}
